/**
 * Created by Dalyn on 2017/3/3.
 */
import React from 'react';
import { Router, Route, hashHistory,IndexRoute } from 'react-router';
import EventManager from '../util/EventManager.js'
import Welcome from "./Welcome.js";
import Account from "./Account.js";
import Find_pw1 from "./Find_pw1.js";
import Find_pw2 from "./Find_pw2.js";
import Reset_pw1 from "./Reset_pw1.js";

const config = [
    {name: "欢迎", path: "/welocme(/:channel)", component: Welcome, isShowTitle: false},
    {name: "企业", path: "/myaccount", component: Account, isShowTitle: false},
    {name: "找回密码1", path: "/find_pw1", component: Find_pw1, isShowTitle: false},
    {name: "找回密码2", path: "/find_pw2(/:token)", component: Find_pw2, isShowTitle: false},
    {name: "重置密码1", path: "/reset_pw1(/:token)", component: Reset_pw1, isShowTitle: false},
];


class LoginMain extends React.Component {
    constructor(props){
        super(props);
        this.state={
            isCompany:true
        }
    }
    componentWillMount() {
        EventManager.on('isCompany',(param)=>{
            this.setState({
                isCompany:param
            });
        })
    }
    render(){
        return (
            <div style={Style.login}>
                <div className="login_wrap">
                    <div style={Style.logoBox}>
                        <img style={Style.logo} src="./img/logo.png" alt=""/>
                    </div>
                    <div style={Style.bannerBox}>
                        <div style={Style.loginBox}>
                            {this.props.children}
                        </div>
                    </div>
                    <div style={Style.footer}>
                        <p style={Style.p1}>北京公安局分局备案编号110105014669 | 京ICP备09055871号-2 | 互联网出版许可证编号新出网证（京）字150号</p>
                        <p style={Style.p1}>Copyright 2014-2015 衣有道 （北京）有限公司版权所有</p>
                    </div>
                </div>
            </div>

        )
    }
}
export default class Login extends React.Component {
    /*默认属性状态*/
    constructor(props){
        super(props);
    }

    /*渲染*/
    render() {
        return (
            /*路由组件*/
            <Router history={hashHistory}>
                <Route path="/" component={LoginMain}>
                    <IndexRoute component={Welcome}/>
                    {
                        config.map((item,index) => {
                            return <Route {...item} key={index+'_'}/>
                        })
                    }
                </Route>
            </Router>
        );
    }
}
var Style = {
    login:{
        width:"100%",
        background:"#fff",
        position:"relative",
        overflow:"hidden"
    },
    logoBox:{
        width:"235px",
        height:"68px",
        margin:"0 auto",
        padding:"60px 0",
    },
    logo:{
        width:"100%",
        height:"100%"
    },
    bannerBox:{
        position:"relative",
        width:'82%',
        height:"430px",
        margin:"20px auto",
        background:"url('./img/login_bg.jpg') no-repeat",
    },
    loginBox:{
        position:"absolute",
        top:53,
        right:'16%',
        width:"343px",
        height:"349px",
        background:"#fff",
        border:"1px solid #b2b2b2",
        borderRadius:"8px"
    },
    footer:{
        width:"700px",
        height:"50px",
        margin:"92px auto"
    },
    p1:{
        width:"100%",
        height:"28px",
        fontSize:"12px",
        color:"#4c4c4c",
        lineHeight:"28px",
        textAlign:"center",
    }
};
